package jehc.djshi.log.web;

import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import jehc.djshi.common.annotation.NeedLoginUnAuth;
import jehc.djshi.common.base.BaseAction;
import jehc.djshi.common.base.BasePage;
import jehc.djshi.common.base.BaseResult;
import jehc.djshi.common.base.BaseSearch;
import jehc.djshi.common.util.StringUtil;
import jehc.djshi.log.model.XtOperateBusinessLogs;
import jehc.djshi.log.service.XtOperateBusinessLogsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Desc 平台业务操作日志
 * @Author 邓纯杰
 * @CreateTime 2012-12-12 12:12:12
 */
@RestController
@RequestMapping("/xtOperateBusinessLogs")
@Api(value = "平台业务操作日志API",description = "平台业务操作日志API")
public class XtOperateBusinessLogsController extends BaseAction {
	@Autowired
	private XtOperateBusinessLogsService xtOperateBusinessLogsService;
	
	/**
	* 分页查询
	* @param baseSearch
	*/
	@NeedLoginUnAuth
	@PostMapping(value="/list")
	@ApiOperation(value="分页查询", notes="分页查询")
	public BasePage getXtOperateBusinessLogsListByCondition(@RequestBody(required=true)BaseSearch baseSearch){
		Map<String, Object> condition = baseSearch.convert();
		commonHPager(baseSearch);
		List<XtOperateBusinessLogs> xt_Operate_Business_LogsList = xtOperateBusinessLogsService.getXtOperateBusinessLogsListByCondition(condition);
		PageInfo<XtOperateBusinessLogs> page = new PageInfo<XtOperateBusinessLogs>(xt_Operate_Business_LogsList);
		return outPageBootStr(page,baseSearch);
	}
	
	/**
	* 查询单条记录
	* @param xt_operate_business_logs_id
	*/
	@NeedLoginUnAuth
	@GetMapping(value="/get/{xt_operate_business_logs_id}")
	@ApiOperation(value="查询单条记录", notes="查询单条记录")
	public BaseResult getXtOperateBusinessLogsById(@PathVariable("xt_operate_business_logs_id")String xt_operate_business_logs_id){
		XtOperateBusinessLogs xt_Operate_Business_Logs = xtOperateBusinessLogsService.getXtOperateBusinessLogsById(xt_operate_business_logs_id);
		return outDataStr(xt_Operate_Business_Logs);
	}
	
	/**
	* 删除
	* @param xt_operate_business_logs_id
	*/
	@DeleteMapping(value="/delete")
	@ApiOperation(value="删除平台业务操作日志", notes="删除平台业务操作日志")
	public BaseResult delXtOperateBusinessLogs(String xt_operate_business_logs_id){
		int i = 0;
		if(!StringUtil.isEmpty(xt_operate_business_logs_id)){
			Map<String, Object> condition = new HashMap<String, Object>();
			condition.put("xt_operate_b_logs_id",xt_operate_business_logs_id.split(","));
			i=xtOperateBusinessLogsService.delXtOperateBusinessLogs(condition);
		}
		if(i>0){
			return outAudStr(true);
		}else{
			return outAudStr(false);
		}
	}
}
